package com.dongdongshop.core;

import java.io.Serializable;

public enum MemberEnum implements Serializable {
    SUCCESS(111,"操作成功"),ERROR(222,"操作失败"),UNAUTHORIZED(333,"权限不足");

    private Integer code;
    private String message;

    MemberEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Integer gainCode(String message){
        MemberEnum[] values = MemberEnum.values();
        for (MemberEnum me:values){
            if(message.equals(me.getMessage())){
                return me.getCode();
            }
        }
        return null;
    }
    public static String gainMessage(Integer code){
        MemberEnum[] values = MemberEnum.values();
        for (MemberEnum me:values){
            if(code==me.getCode()){
                return me.getMessage();
            }
        }
        return null;
    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
